package model

import (
	"fmt"
	"gitee.com/xujianpeng/testmod"
)

/**
F:\001------Code\GOPATH\src\go-learning>go run cmd/main.go
cmd\main.go:4:2: package go-learning/mod is not in GOROOT (E:\go\src\go-learning\mod)


上述为什么不识别GOPATH了，因为开始了go mod
如上这个不行，是因为项目里面开启了go mod 环境变量，但是该项目没有使用go mod init mod
module mod

go 1.14

生成一个go.mod 文件

F:\001------Code\GOPATH\src\go-learning>go build cmd/main.go
cmd\main.go:4:2: package go-learning/mod is not in GOROOT (E:\go\src\go-learning\mod)


F:\001------Code\GOPATH\src\go-learning>go get gitee.com/xujianpeng/testmod
go: downloading gitee.com/xujianpeng/testmod v0.0.0-20210304092028-a31cf01e10b4
go: gitee.com/xujianpeng/testmod upgrade => v0.0.0-20210304092028-a31cf01e10b4
go get: gitee.com/xujianpeng/testmod@v0.0.0-20210304092028-a31cf01e10b4: parsing go.mod:
        module declares its path as: testmod
                but was required as: gitee.com/xujianpeng/testmod

第一个是go.mod 里面写的。。第二个是下载的时候用的目录。


F:\001------Code\GOPATH\src\go-learning>go get  gitee.com/xujianpeng/testmod
go get gitee.com/xujianpeng/testmod: no matching versions for query "upgrade"

感觉这时候可以了。。。。。go.mod要一样。

F:\001------Code\GOPATH\src\go-learning>go build cmd/main.go
go: finding module for package gitee.com/xujianpeng/testmod
cmd\main.go:5:2: no matching versions for query "latest"

F:\001------Code\GOPATH\src\go-learning>go get  gitee.com/xujianpeng/testmod
go: downloading gitee.com/xujianpeng/testmod v1.0.0
go get gitee.com/xujianpeng/testmod: gitee.com/xujianpeng/testmod@v1.0.0: verifying module: gitee.com/xujianpeng/testmod@v1.0.0: reading https://mirrors
.aliyun.com/goproxy/sumdb/sum.golang.org/lookup/gitee.com/xujianpeng/testmod@v1.0.0: 410 Gone
        server response: not found: gitee.com/xujianpeng/testmod@v1.0.0: unrecognized import path "gitee.com/xujianpeng/testmod": https fetch: Get "http
s://gitee.com/xujianpeng/testmod?go-get=1": dial tcp 212.64.62.183:443: connect: connection refused


按照流程，切换分支之后
F:\001------Code\GOPATH\src\go-learning>go get  gitee.com/xujianpeng/testmod
go get gitee.com/xujianpeng/testmod: no matching versions for query "upgrade"


go get gitee.com/xujianpeng/testmod/...: module gitee.com/xujianpeng/testmod: Get "https://proxy.golang.org/gitee.com/xujianpeng/testmod/@v/list": dial tcp 216.58.200.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

F:\001------Code\GOPATH\src\go-learning>go get  gitee.com/xujianpeng/testmod
go get gitee.com/xujianpeng/testmod: module gitee.com/xujianpeng/testmod: Get "https://proxy.golang.org/gitee.com/xujianpeng/testmod/@v/list": dial tcp
172.217.160.113:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond.

F:\001------Code\GOPATH\src\go-learning>go get  gitee.com/xujianpeng/testmod
go: downloading gitee.com/xujianpeng/testmod v1.0.0
go get gitee.com/xujianpeng/testmod: gitee.com/xujianpeng/testmod@v1.0.0: verifying module: gitee.com/xujianpeng/testmod@v1.0.0: reading https://mirrors
.aliyun.com/goproxy/sumdb/sum.golang.org/lookup/gitee.com/xujianpeng/testmod@v1.0.0: 410 Gone
        server response: not found: gitee.com/xujianpeng/testmod@v1.0.0: unrecognized import path "gitee.com/xujianpeng/testmod": https fetch: Get "http
s://gitee.com/xujianpeng/testmod?go-get=1": dial tcp 212.64.62.183:443: connect: connection refused


go env -w GOSUMDB=off  之后就好了

F:\001------Code\GOPATH\src\go-learning>go get  gitee.com/xujianpeng/testmod
go: downloading gitee.com/xujianpeng/testmod v1.0.0
go: gitee.com/xujianpeng/testmod upgrade => v1.0.0

相应的目录GOPATH 的pkg下面就有了

F:\001------Code\GOPATH\src\go-learning>go build cmd/main.go
没有输出，但是go.mod多了
require gitee.com/xujianpeng/testmod v1.0.0 // indirect


还需要打开idea的配置打开才行。。。然后
F:\001------Code\GOPATH\src\go-learning>go run cmd/main.go
Hi, xjp



*/
func Test() {

	fmt.Println(testmod.Hi("xjp"))
}
